﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

namespace FirstFloor.Documents.Pdf.ColorSpaces
{
    /// <summary>
    /// Represents the DeviceCMYK color space.
    /// </summary>
    internal class DeviceCMYK
        : ColorSpace
    {
        private static DeviceCMYK @default = new DeviceCMYK();

        private DeviceCMYK()
        {
            this.Name = "DeviceCMYK";
            this.DefaultColor = new double[] { 0, 0, 0, 1 };
        }

        /// <summary>
        /// Gets the DeviceCMYK color space.
        /// </summary>
        /// <value>The default.</value>
        public static DeviceCMYK Default
        {
            get { return @default; }
        }

        /// <summary>
        /// Converts specified value to the XYZ color space.
        /// </summary>
        /// <param name="values">The values.</param>
        /// <returns></returns>
        public override ColorPoint ToXYZ(double[] values)
        {
            var rgb = new double[3];

            rgb[0] = 1D - Math.Min(1D, values[0] + values[3]);
            rgb[1] = 1D - Math.Min(1D, values[1] + values[3]);
            rgb[2] = 1D - Math.Min(1D, values[2] + values[3]);

            return DeviceRGB.Default.ToXYZ(rgb);
        }
    }
}
